﻿using System;
using System.Collections.ObjectModel;
using System.ComponentModel;

namespace RemoteTestRunner.BusinessLogic.ViewModels
{
    public class ProjectViewModel : INotifyPropertyChanged
    {
        public ProjectViewModel()
        {
            Tests = new ObservableCollection<TestViewModel>();
        }

        #region Id (INotifyPropertyChanged Property)

        private int _id;

        public int Id
        {
            get { return _id; }
            set
            {
                if (_id != value)
                {
                    _id = value;
                    OnPropertyChanged("Id");
                }
            }
        }

        #endregion

        #region Name (INotifyPropertyChanged Property)

        private string _name;

        public string Name
        {
            get { return _name; }
            set
            {
                if (_name != value)
                {
                    _name = value;
                    OnPropertyChanged("Name");
                }
            }
        }

        #endregion

        #region CreatedBy (INotifyPropertyChanged Property)

        private string _createdBy;

        public string CreatedBy
        {
            get { return _createdBy; }
            set
            {
                if (_createdBy != value)
                {
                    _createdBy = value;
                    OnPropertyChanged("CreatedBy");
                }
            }
        }

        #endregion

        #region CreatedDate (INotifyPropertyChanged Property)

        private DateTime _createdDate;

        public DateTime CreatedDate
        {
            get { return _createdDate; }
            set
            {
                if (_createdDate != value)
                {
                    _createdDate = value;
                    OnPropertyChanged("CreatedDate");
                }
            }
        }

        #endregion

        #region ModifiedBy (INotifyPropertyChanged Property)

        private string _modifiedBy;

        public string ModifiedBy
        {
            get { return _modifiedBy; }
            set
            {
                if (_modifiedBy != value)
                {
                    _modifiedBy = value;
                    OnPropertyChanged("ModifiedBy");
                }
            }
        }

        #endregion

        #region ModifiedDate (INotifyPropertyChanged Property)

        private DateTime _modifiedDate;

        public DateTime ModifiedDate
        {
            get { return _modifiedDate; }
            set
            {
                if (_modifiedDate != value)
                {
                    _modifiedDate = value;
                    OnPropertyChanged("ModifiedDate");
                }
            }
        }

        #endregion

        #region Tests (INotifyPropertyChanged Property)

        private ObservableCollection<TestViewModel> _tests;

        public ObservableCollection<TestViewModel> Tests
        {
            get { return _tests; }
            set
            {
                _tests = value;
                OnPropertyChanged("Tests");
            }
        }

        #endregion

        #region INotifyPropertyChanged values

        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string propertyName)
        {
            var handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #endregion
    }
}